<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //catch专门用来处理失败状态
        //catch()可以捕获它前面的错误
        //一般建议，Promise对象后面要跟catch方法这样可以处理Promise后面发生的错误
        new Promise((resolve, reject) => {
                //resolve(123);
                reject('reason');
            })
            .then((data) => {
                console.log('success', data);
            })


        .catch((err) => {
                console.log(err);
                //return undefined;默
                throw new Error('reason')
            })
            .then(data => {
                console.log(data);
            }).catch((err) => {
                console.log(err);
            })
    </script>
</body>

</html>